﻿package mortal.game.utils
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;

    public class CareerUtil extends Object
    {
        public static var allCareer:Array = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048];
        private static const SkillColor:Object = {1:16776960, 2:16776960, 4:16776960, 8:16776960};
        private static const SkillColorStr:Object = {1:"#ffff00", 2:"#ffff00", 4:"#ffff00", 8:"#ffff00"};
        private static const CareerColorStr:Object = {1:"#fff200", 2:"#29caff", 4:"#f26522", 8:"#ff00e9"};

        public function CareerUtil()
        {
            return;
        }// end function

        public static function getCareerArray(param1:int) : Array
        {
            var _loc_3:int = 0;
            var _loc_2:Array = [];
            var _loc_4:int = 0;
            while (_loc_4 < allCareer.length)
            {
                
                _loc_3 = allCareer[_loc_4] as int;
                if ((param1 & _loc_3) != 0)
                {
                    _loc_2.push(_loc_3);
                }
                _loc_4++;
            }
            return _loc_2;
        }// end function

        public static function getCareerName(param1:int) : String
        {
            var _loc_2:* = GameDefConfig.instance.getECareer(param1);
            if (_loc_2)
            {
                return _loc_2.text;
            }
            return "";
        }// end function

        public static function getEquipCareerName(param1:int) : String
        {
            var _loc_4:int = 0;
            var _loc_8:String = null;
            var _loc_2:String = "";
            var _loc_3:* = getCareerArray(param1);
            var _loc_5:TCareer = null;
            var _loc_6:* = _loc_3.length;
            var _loc_7:int = 0;
            while (_loc_7 < _loc_6)
            {
                
                _loc_4 = _loc_3[_loc_7] as int;
                _loc_8 = getCareerName(_loc_4);
                if (_loc_5)
                {
                    if (_loc_7 == (_loc_3.length - 1))
                    {
                        if (_loc_7 != 0)
                        {
                            _loc_2 = _loc_2 + "、";
                        }
                        _loc_2 = _loc_2 + _loc_8;
                    }
                    else
                    {
                        _loc_2 = _loc_2 + _loc_8;
                    }
                }
                _loc_7++;
            }
            return _loc_2;
        }// end function

        public static function isCareerSuit(param1:int, param2:int) : Boolean
        {
            return param1 == ECareer._ECareerNo || (param1 & param2) > 0;
        }// end function

        public static function isMagicCareer(param1:int = -1) : Boolean
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            switch(param1)
            {
                case ECareer._ECareerMageEx:
                case ECareer._ECareerPriestEx:
                case ECareer._ECareerMage:
                case ECareer._ECareerPriest:
                {
                    return true;
                }
                default:
                {
                    break;
                }
            }
            return false;
        }// end function

        public static function isPhysicalCareer(param1:int = -1) : Boolean
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            switch(param1)
            {
                case ECareer._ECareerArcher:
                case ECareer._ECareerWarrior:
                case ECareer._ECareerWarriorEx:
                case ECareer._ECareerArcherEx:
                {
                    return true;
                }
                default:
                {
                    break;
                }
            }
            return false;
        }// end function

        public static function isNewPlayerOrNoCareer(param1:int) : Boolean
        {
            if (param1 == ECareer._ECareerNo)
            {
                return true;
            }
            return false;
        }// end function

        public static function isGradeCareer(param1:int = -1) : Boolean
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            switch(param1)
            {
                case ECareer._ECareerWarriorEx:
                case ECareer._ECareerArcherEx:
                case ECareer._ECareerMageEx:
                case ECareer._ECareerPriestEx:
                {
                    return true;
                }
                default:
                {
                    break;
                }
            }
            return false;
        }// end function

        public static function getGradeCareer(param1:int = -1) : int
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            switch(param1)
            {
                case ECareer._ECareerWarrior:
                {
                    return ECareer._ECareerWarriorEx;
                }
                case ECareer._ECareerArcher:
                {
                    return ECareer._ECareerArcherEx;
                }
                case ECareer._ECareerMage:
                {
                    return ECareer._ECareerMageEx;
                }
                case ECareer._ECareerPriest:
                {
                    return ECareer._ECareerPriestEx;
                }
                default:
                {
                    break;
                }
            }
            return param1;
        }// end function

        public static function getBaseCareer(param1:int = -1) : int
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            switch(param1)
            {
                case ECareer._ECareerWarriorEx:
                {
                    return ECareer._ECareerWarrior;
                }
                case ECareer._ECareerArcherEx:
                {
                    return ECareer._ECareerArcher;
                }
                case ECareer._ECareerMageEx:
                {
                    return ECareer._ECareerMage;
                }
                case ECareer._ECareerPriestEx:
                {
                    return ECareer._ECareerPriest;
                }
                default:
                {
                    break;
                }
            }
            return param1;
        }// end function

        public static function getSkillColor(param1:int = -1) : uint
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            param1 = getBaseCareer(param1);
            return SkillColor[param1];
        }// end function

        public static function getSkillColorString(param1:int = -1) : String
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            param1 = getBaseCareer(param1);
            return SkillColorStr[param1];
        }// end function

        public static function getCareerColorString(param1:int = -1) : String
        {
            if (param1 == -1)
            {
                param1 = Cache.instance.role.entityInfo.career;
            }
            param1 = getBaseCareer(param1);
            return CareerColorStr[param1];
        }// end function

    }
}
